package com.adingxiong.cft.design.abstractfactory;

/**
 * @ClassName ShapeFactory
 * @Description
 * @Author xiongchao
 * @Date 2021/1/7 15:05
 **/
public class ShapeFactory extends AbstractFactory {


    /**
     *  通过 getType() 方法来匹配需要实现那个类
     * @param
     * @return
     */
    @Override
    Color getColor(String color) {
        return null;
    }

    @Override
    Shape getShape(String type) {
        if(type == null) {
            return null;
        }
        if(type.equalsIgnoreCase("circle")){
            return new Circle();
        } else if (type.equalsIgnoreCase("rectangle")){
            return new Rectangle();
        } else if (type.equalsIgnoreCase("square")){
            return new Square();
        } else {
            return null;
        }
    }
}
